
let isMemo = false;

export function setUserStorage(user,mem = isMemo) {
    if(mem)isMemo = true;
    delUserFromStorage();
    const storage = mem ? localStorage : sessionStorage;
    storage.setItem("user",JSON.stringify(user));
}

export function fetchUserFromStorage() {
    let res = localStorage.getItem("user");
    if(!res)res = sessionStorage.getItem("user");
    if(!res)return res;
    return JSON.parse(res);
}


export function delUserFromStorage() {
    localStorage.removeItem("user");
    sessionStorage.removeItem("user");
}